<?php
namespace app\serverfund\service\order;

use \app\manage\service\ApiBase;
/**
 * @author:      李颖
 * @DateTime:    2017-12-15 16:00:29
 * @Description: 有关订单的操作
 */
class Order extends ApiBase
{
    protected $orderValidate = '\app\serverfund\validate\Order';
	protected $orderLogic = '\app\serverfund\logic\Order';

    //我的 - 支付订单  user_info为数组格式
    public function payOrderTransactionOperate(): array 
    {
        $data = $this->haveIssetReceiveData(['id'=>0, 'user_id'=>0, 'integral_deduction'=>0, 'integral_deduction_money'=>0, 'integral_deduction_currency'=>0, 'pay_method'=>' ', 'order_goods_info'=>[], 'opposite_id'=>0, 'update_ip'=>' ', 'app_id'=>0, 'user_info'=>[], 'opposite_info'=>[]]);

        $checkOrderGoods = $this->_checkOrderGoods($data['order_goods_info']);
        if($checkOrderGoods['status'] != SUCCESS_STATUS){
            return $checkOrderGoods;
        }

        return $this->stepRun($data, 'payOrderTransactionOperate');
    }

    protected function _checkOrderGoods($orderGoodsInfo): array 
    {
        if(!$orderGoodsInfo){ return verify_err(null, '请传入购买的商品信息'); }

        $validate = validate($this->orderValidate);
        foreach ($orderGoodsInfo as $k => $v) {
            if(!$validate->scene('checkOrderPrice')->check($v)){
                return verify_err(null, $validate->getError());
            }
        }
        return auto_success($orderGoodsInfo, '数据格式没有问题');
    }

}